define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'tags/index',
                    add_url: 'tags/add',
                    edit_url: 'tags/edit',
                    del_url: 'tags/del',
                    multi_url: 'tags/multi',
                    table: 'tags',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'title', title: __('Title')},
                        {field: 'status', title: __('Status'), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'member.id', title: __('Member.id')},
                        {field: 'member.user_name', title: __('Member.user_name')},
                        {field: 'member.birthday', title: __('Member.birthday'), operate:'RANGE', addclass:'datetimerange'},
                        {field: 'member.mobile', title: __('Member.mobile')},
                        {field: 'member.wechat', title: __('Member.wechat')},
                        {field: 'member.wechat_image', title: __('Member.wechat_image'), formatter: Table.api.formatter.image},
                        {field: 'member.avatar', title: __('Member.avatar')},
                        {field: 'member.images', title: __('Member.images'), formatter: Table.api.formatter.images},
                        {field: 'member.gender', title: __('Member.gender')},
                        {field: 'member.birth_province', title: __('Member.birth_province')},
                        {field: 'member.live_province', title: __('Member.live_province')},
                        {field: 'member.id_image', title: __('Member.id_image'), formatter: Table.api.formatter.image},
                        {field: 'member.live_district', title: __('Member.live_district')},
                        {field: 'member.height', title: __('Member.height')},
                        {field: 'member.weight', title: __('Member.weight')},
                        {field: 'member.education_id', title: __('Member.education_id')},
                        {field: 'member.income_id', title: __('Member.income_id')},
                        {field: 'member.zodiac_id', title: __('Member.zodiac_id')},
                        {field: 'member.marriage_id', title: __('Member.marriage_id')},
                        {field: 'member.car_id', title: __('Member.car_id')},
                        {field: 'member.house_id', title: __('Member.house_id')},
                        {field: 'member.worker', title: __('Member.worker')},
                        {field: 'member.authen_status', title: __('Member.authen_status'), formatter: Table.api.formatter.status},
                        {field: 'member.rec_status', title: __('Member.rec_status'), formatter: Table.api.formatter.status},
                        {field: 'member.rec_start_time', title: __('Member.rec_start_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'member.rec_end_time', title: __('Member.rec_end_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'member.up_num', title: __('Member.up_num')},
                        {field: 'member.tags_ids', title: __('Member.tags_ids')},
                        {field: 'member.last_login_time', title: __('Member.last_login_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'member.create_time', title: __('Member.create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});